<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
    <title>Zero Clipboard Test</title>
    <!-- <script type="text/javascript" src="jquery-1.8.3_min.js"></script> -->
    <script type="text/javascript" src="./js/jQuery-2.1.4.min.js"></script>
    <script type="text/javascript" src="./js/jquery.qrcode.min.js"></script>
    <script type="text/javascript"> 
    function generateQRCode(rendermethod, picwidth, picheight, url) {
    $("#qrcode").qrcode({ 
            render: rendermethod, // 渲染方式有table方式（IE兼容）和canvas方式
            width: picwidth, //宽度 
            height:picheight, //高度 
            text: utf16to8(url), //内容 
            typeNumber:-1,//计算模式
            correctLevel:2,//二维码纠错级别
            background:"#ffffff",//背景颜色
            foreground:"#000000"  //二维码颜色

        });
    }
    // 根据什么生成二维码
    function init() {
        // generateQRCode("table",200, 200, "http://redmap.hongyanlv.com/");
        // generateQRCode("table",200, 200, "https://cdn.exh.hongyanlv.com/tp5/showProPC.html?m=t-0yAnUm");
        // generateQRCode("table",200, 200, "https://cdn.exh.hongyanlv.com/tp5/showProPC.html?m=t-ErGtg4");
        // generateQRCode("table",200, 200, "https://cdn.exh.hongyanlv.com/tp5/showProPC.html?m=t-k2sAKy");
        // generateQRCode("table",200, 200, "https://cdn.exh.hongyanlv.com/tp5/showProPC.html?m=t-FRmOhm");
        // generateQRCode("table",200, 200, "https://cdn.hongyanlv.com/showProPC.html?m=t-IjyJQBF");
        // generateQRCode("table",200, 200, "http://hongyanlv.com/bk36");
        generateQRCode("table",200, 200, "http://localhost:3000/");
    }
        //中文编码格式转换
    function utf16to8(str) {
        var out, i, len, c;
        out = "";
        len = str.length;
        for (i = 0; i < len; i++) {
            c = str.charCodeAt(i);
            if ((c >= 0x0001) && (c <= 0x007F)) {
                out += str.charAt(i);
            } else if (c > 0x07FF) {
                out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
                out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            } else {
                out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));
                out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));
            }
        }
        return out;
    }   

    </script>
</head>
<body onLoad="init()">
    <h1>Qrcode</h1>
    <div id="qrcode"></div>
</body>
</html>